home *** CD-ROM | disk | FTP | other *** search
- property howManyHats, hardHatBmap, hatsInRow, horizDist, vertDist, trailsSprite, originX, originY, numberSlotLocH, numberSlotLocV, firstNumeral, firstNumeralChan, displayDigits, counterNumber, animCounter, minLoops, bgChannel, hatLoopLength, hLoc, vLoc
- global gActorList, gHiddenActorList, gRollAnimButton, gMenuObject, gAwardsObject, gCDpath
-
- on birth me
- set howManyHats to 0
- set hardHatBmap to the number of cast "OneHardHat"
- set hatsInRow to 10
- set horizDist to 59
- set vertDist to 35
- set trailsSprite to 8
- set originX to 55
- set originY to 28
- set numberSlotLocH to 77
- set numberSlotLocV to 433
- set firstNumeralChan to 4
- set bgChannel to 2
- set displayDigits to 3
- set minLoops to 2
- set hatLoopLength to 4
- set firstNumeral to the number of cast "ZeroBitmap"
- return me
- end
-
- on setup me
- drawHardHats(me)
- add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gHardHatObject, me )", 11, 11, 5, "RCA-07VO01", "RCA-07RO01"))
- add(gActorList, birth(script "Rollover Anim Button Class", "help( gHardHatObject, me )", 12, 12, 11, EMPTY, "RCA-05RO02"))
- puppetAll()
- if howManyHats > 0 then
- giveAward(gAwardsObject, "HardHat")
- end if
- end
-
- on update me
- if counterNumber < howManyHats then
- if animCounter < hatLoopLength then
- set animCounter to animCounter + 1
- set the castNum of sprite 48 to hardHatBmap + animCounter
- else
- finishNumberSound(me)
- resetSprites(me)
- set counterNumber to counterNumber + 1
- set displayString to padString(me, counterNumber, displayDigits)
- refreshCounter(me, displayString)
- set row to ((counterNumber - 1) / 10) + 1
- set column to counterNumber - (10 * (row - 1))
- set hLoc to originX + ((column - 1) * horizDist)
- set vLoc to originY + ((row - 1) * vertDist)
- set animCounter to 1
- set the castNum of sprite 48 to hardHatBmap + animCounter
- set the locH of sprite 48 to hLoc
- set the locV of sprite 48 to vLoc
- sound playFile 1, gCDpath & "SOUND:NUMBERS:" & string(counterNumber) & ".AIF"
- end if
- else
- if animCounter < hatLoopLength then
- set animCounter to animCounter + 1
- set the castNum of sprite 48 to hardHatBmap + animCounter
- else
- finishNumberSound(me)
- set gActorList to []
- showAllActors()
- resetSprites(me)
- set the mouseDownScript to EMPTY
- puppetSound(0)
- end if
- end if
- puppetTempo(15)
- end
-
- on finishNumberSound me
- if soundBusy(1) then
- set the castNum of sprite 48 to hardHatBmap
- go(the frame)
- abort()
- end if
- end
-
- on countOff me
- if (getPos(gActorList, me) = 0) and (howManyHats > 0) then
- eraseAllHats(me)
- set counterNumber to 1
- set displayString to padString(me, counterNumber, displayDigits)
- refreshCounter(me, displayString)
- set animCounter to 1
- set the locH of sprite 48 to originX
- set the locV of sprite 48 to originY
- set the castNum of sprite 48 to hardHatBmap + animCounter
- add(gActorList, me)
- hideOtherActors(me)
- sound playFile 1, gCDpath & "SOUND:NUMBERS:" & string(counterNumber) & ".AIF"
- set the mouseDownScript to "interruptCounting"
- end if
- end
-
- on interruptCountOff me
- removeSprite(48)
- eraseAllHats(me)
- set gActorList to []
- set displayString to padString(me, howManyHats, displayDigits)
- refreshCounter(me, displayString)
- drawHardHats(me)
- set the mouseDownScript to EMPTY
- showAllActors()
- puppetSound(0)
- end
-
- on addHat me, soundName
- if howManyHats < 100 then
- set howManyHats to howManyHats + 1
- end if
- puppetSound(soundName)
- removeSprite(the clickOn)
- updateStage()
- puppetSprite(the clickOn, 0)
- repeat while soundBusy(1)
- end repeat
- puppetSound(0)
- end
-
- on eraseAllHats me
- set the castNum of sprite trailsSprite to the castNum of sprite bgChannel
- set the locH of sprite trailsSprite to the locH of sprite bgChannel
- set the locV of sprite trailsSprite to the locV of sprite bgChannel
- updateStage()
- removeSprite(trailsSprite)
- end
-
- on predraw me
- set displayString to padString(me, howManyHats, displayDigits)
- refreshCounter(me, displayString)
- end
-
- on refreshCounter me, displayString
- repeat with slot = 1 to displayDigits
- set channel to firstNumeralChan + slot - 1
- set bitmapOffset to value(char slot of displayString)
- set the castNum of sprite channel to firstNumeral + bitmapOffset
- set the locH of sprite channel to numberSlotLocH + ((slot - 1) * 32)
- set the locV of sprite channel to numberSlotLocV
- puppetSprite(channel, 1)
- end repeat
- end
-
- on padString me, someNumber, totalDigits
- set stringNumber to string(someNumber)
- set stringLength to length(stringNumber)
- set paddedString to EMPTY
- repeat with x = 1 to totalDigits - stringLength
- set paddedString to paddedString & "0"
- end repeat
- repeat with x = 1 to stringLength
- set paddedString to paddedString & char x of stringNumber
- end repeat
- return paddedString
- end
-
- on drawHardHats me
- set the castNum of sprite trailsSprite to hardHatBmap
- set columnCounter to 0
- set rowCounter to 1
- repeat with x = 1 to howManyHats
- set columnCounter to columnCounter + 1
- if columnCounter > hatsInRow then
- set columnCounter to 1
- set rowCounter to rowCounter + 1
- end if
- set the locH of sprite trailsSprite to originX + ((columnCounter - 1) * horizDist)
- set the locV of sprite trailsSprite to originY + ((rowCounter - 1) * vertDist)
- updateStage()
- end repeat
- removeSprite(trailsSprite)
- updateStage()
- end
-
- on resetSprites me
- set the castNum of sprite 48 to hardHatBmap
- set the locH of sprite trailsSprite to the locH of sprite 48
- set the locV of sprite trailsSprite to the locV of sprite 48
- set the castNum of sprite trailsSprite to hardHatBmap
- updateStage()
- removeSprite(48)
- updateStage()
- removeSprite(trailsSprite)
- updateStage()
- end
-
- on saveHardHats me
- set hardHatData to string(howManyHats) & ","
- return hardHatData
- end
-
- on loadHardHats me, index
- set howManyHats to value(item index of the dataString of gMenuObject)
- return index + 1
- end
-
- on goMenu me, buttonObject
- clearAllActors()
- unpuppetAll()
- makeButtonJump(buttonObject)
- puppetPalette("HardHatPal")
- go("Grass")
- puppetPalette("MainPal")
- unLoadCast()
- goLocationMap()
- end
-
- on help me, buttonObject
- birth(script "Help Parent", buttonObject, #HardHat)
- end
-